<div class="layui-fluid" id="VIEW-list-table" lay-title="订单列表">
    <div class="layui-row layui-col-space10">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">筛选数据</div>
                <div class="layui-card-body">
                    <form class="layui-form" lay-filter="lig-order-searchform">
                        <div class="layui-inline">
                            <label class="layui-form-label">订单号</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="code" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <input type="button" class="layui-btn layui-btn-sm" lay-filter="lig-order-search" lig-lang="btn-search" value="查询"/>
                            <input type="reset" class="layui-btn layui-btn-sm layui-btn-primary" value=" 重 置 "/>
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" lay-filter="lig-order-imp">
                                <i class="layui-icon layui-icon-export"></i>批量导入
                            </button>
                        </div>
                    </form>
                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-body nepadmin-table-full">
                    <div class="layui-btn-container nepadmin-pad-t10 nepadmin-pad-l10">
                        <div class="layui-btn layui-btn-sm" lay-filter="lig-order-add">添加</div> 
                        <div class="layui-btn layui-btn-sm layui-btn-primary" lay-filter="lig-order-remove">删除</div>
                    </div>
                    <table lay-filter="lig-order-table"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="tpl-row-toolBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs lig-modify" lay-event="lig-modify" title="修改">修改</a>
</script>
<script type="text/html" id="tpl-order-add">
    <form class="layui-form" style="padding: 20px 20px 0 0;" lay-filter="lig-saveForm">
        
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">日期</label>
                <div class="layui-input-block">
                    <input type="text" name="deliveryDate" autocomplete="off" class="layui-input"
                           value="" lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">班次</label>
                <div class="layui-input-block">
                    <input type="text" name="deliveryShift" autocomplete="off" class="layui-input"
                           value="" lay-verify="required">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">地址</label>
                <div class="layui-input-block">
                    <input type="text" name="consignorAddress" autocomplete="off" class="layui-input"
                           value="" lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">工厂门牌号</label>
                <div class="layui-input-block">
                    <input type="text" name="consignorHouseNumber" autocomplete="off" class="layui-input"
                           value="" lay-verify="required">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">市场</label>
                <div class="layui-input-block">
                    <input type="text" name="receiverAddress" autocomplete="off" class="layui-input"
                           value="" lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">档口号</label>
                <div class="layui-input-block">
                    <input type="text" name="receiverHouseNumber" autocomplete="off" class="layui-input"
                           value="" lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">收包员</label>
                <div class="layui-input-block">
                    <input type="text" name="receiverName" autocomplete="off" class="layui-input" value='' lay-verify="required">
                </div>
            </div>
        </div>
        
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">驾驶员</label>
                <div class="layui-input-block">
                    <input type="text" name="driverName" autocomplete="off" class="layui-input" value='' lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">车牌号</label>
                <div class="layui-input-block">
                    <input type="text" name="vehicleNumber" autocomplete="off" class="layui-input" value='' lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">拉包工</label>
                <div class="layui-input-block">
                    <input type="text" name="carrierName" autocomplete="off" class="layui-input" value='' lay-verify="required">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">类别</label>
                <div class="layui-input-block">
                    <input type="text" name="cargoType" autocomplete="off" class="layui-input"
                           value="" lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">数量</label>
                <div class="layui-input-block">
                    <input type="text" name="cargoNum" autocomplete="off" class="layui-input"
                           value="" lay-verify="required">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">运费</label>
                <div class="layui-input-block">
                    <input type="text" name="driverFee" autocomplete="off" class="layui-input" value='' lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">拉包费</label>
                <div class="layui-input-block">
                    <input type="text" name="carrierFee" autocomplete="off" class="layui-input" value='' lay-verify="required">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">市场付款</label>
                <div class="layui-input-block">
                    <input type="text" name="marketAmount" autocomplete="off" class="layui-input" value='' lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">收款</label>
                <div class="layui-input-block">
                    <input type="text" name="payStatus" autocomplete="off" class="layui-input" value='' lay-verify="required">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="remark" class="layui-textarea" style="height:40px;line-height:20px;"></textarea>
            </div>
        </div>
    </form>
</script>
<script type="text/html" id="tpl-order-modify">
    <form class="layui-form" style="padding: 20px 20px 0 0;" lay-filter="lig-saveForm">
        <input type="hidden" name="id" value="{{d.id}}">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">日期</label>
                <div class="layui-input-block">
                    <input type="text" name="deliveryDate" autocomplete="off" class="layui-input"
                           value="{{layui.lig.toDateString(d.deliveryDate, 'yyyy-MM-dd') }}" lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">班次</label>
                <div class="layui-input-block">
                    <input type="text" name="deliveryShift" autocomplete="off" class="layui-input"
                           value="{{d.deliveryShift}}" lay-verify="required">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">地址</label>
                <div class="layui-input-block">
                    <input type="text" name="consignorAddress" autocomplete="off" class="layui-input"
                           value="{{d.consignorAddress}}" lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">工厂门牌号</label>
                <div class="layui-input-block">
                    <input type="text" name="consignorHouseNumber" autocomplete="off" class="layui-input"
                           value="{{d.consignorHouseNumber}}" lay-verify="required">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">市场</label>
                <div class="layui-input-block">
                    <input type="text" name="receiverAddress" autocomplete="off" class="layui-input"
                           value="{{d.receiverAddress}}" lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">档口号</label>
                <div class="layui-input-block">
                    <input type="text" name="receiverHouseNumber" autocomplete="off" class="layui-input"
                           value="{{d.receiverHouseNumber}}" lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">收包员</label>
                <div class="layui-input-block">
                    <input type="text" name="receiverName" autocomplete="off" class="layui-input" value='{{d.receiverName}}' lay-verify="required">
                </div>
            </div>
        </div>
        
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">驾驶员</label>
                <div class="layui-input-block">
                    <input type="text" name="driverName" autocomplete="off" class="layui-input" value='{{d.driverName}}' lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">车牌号</label>
                <div class="layui-input-block">
                    <input type="text" name="vehicleNumber" autocomplete="off" class="layui-input" value='{{d.vehicleNumber}}' lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">拉包工</label>
                <div class="layui-input-block">
                    <input type="text" name="carrierName" autocomplete="off" class="layui-input" value='{{d.carrierName}}' lay-verify="required">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">类别</label>
                <div class="layui-input-block">
                    <input type="text" name="cargoType" autocomplete="off" class="layui-input"
                           value='{{d.cargoType}}' lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">数量</label>
                <div class="layui-input-block">
                    <input type="text" name="cargoNum" autocomplete="off" class="layui-input"
                           value='{{d.cargoNum}}' lay-verify="required">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">运费</label>
                <div class="layui-input-block">
                    <input type="text" name="driverFee" autocomplete="off" class="layui-input" value='{{d.driverFee}}' lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">拉包费</label>
                <div class="layui-input-block">
                    <input type="text" name="carrierFee" autocomplete="off" class="layui-input" value='{{d.carrierFee}}' lay-verify="required">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">市场付款</label>
                <div class="layui-input-block">
                    <input type="text" name="marketAmount" autocomplete="off" class="layui-input" value='{{d.marketAmount}}' lay-verify="required">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label ligui-form-item-required">收款</label>
                <div class="layui-input-block">
                    <input type="text" name="payStatus" autocomplete="off" class="layui-input" value='{{d.payStatus}}' lay-verify="required">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="remark" class="layui-textarea" style="height:40px;line-height:20px;">{{d.remark}}</textarea>
            </div>
        </div>
    </form>
</script>
<script>
    layui.use(['admin', 'table', 'form', 'dropdown', 'laytpl', 'jquery','lig'], function (admin, table, form, dropdown, laytpl, $, lig) {
        form.render();

        // 实例代码，加载字典项
        //lig.loadSelectDict('sku_splb', '[lay-filter="lig-order-searchform"] select[name="splb"]');

        lig.table({
            elem: '[lay-filter="lig-order-table"]',
            url: 'order/page',
            cols: [[
                { title: '', type: 'checkbox', fixed: true, width: 60 },
                {title: '操作', toolbar: '#tpl-row-toolBar', align: 'left', width: 70},
                { title: '订单号', field: 'id', width: 140 },
                { title: '日期', field: 'deliveryDate', width: 140,templet: '<div>{{ layui.lig.toDateString(d.deliveryDate, "yyyy-MM-dd") }}</div>', },
                { title: '班次', field: 'deliveryShift', minWidth: 120 },
                { title: '地址', field: 'consignorAddress', width: 140 },
                { title: '收包员', field: 'receiverName', minWidth: 120 },
                { title: '市场', field: 'receiverAddress', minWidth: 120 },
                { title: '档口号', field: 'receiverHouseNumber', minWidth: 120 },
                { title: '类别', field: 'cargoTypeName', minWidth: 120 },
                { title: '数量', field: 'cargoNum', minWidth: 120 },
                { title: '驾驶员', field: 'driverName', minWidth: 120 },
                { title: '车牌号', field: 'vehicleNumber', minWidth: 120 },
                { title: '拉包工', field: 'carrierName', minWidth: 120 },
                { title: '运费', field: 'driverFee', minWidth: 120 },
                { title: '拉包费', field: 'carrierFee', minWidth: 120 },
                { title: '合计', field: 'totalFee', minWidth: 120 },
                { title: '收款', field: 'payStatusName', minWidth: 120 },
                { title: '市场付款', field: 'marketAmount', minWidth: 120 },
                { title: '备注', field: 'remark', minWidth: 120 }

            ]]
        },{
            mode:'dialog',
            entity: 'order',
            primaryField: 'id',
            addContent: $('#tpl-order-add').html(),
            addUrl: 'order/add',
            addTitle: '添加送货单',
            area: ['60%', 'auto'],
            onAddOpened: function() {
            },

            modifyContent: $('#tpl-order-modify').html(),
            modifyUrl: 'order/modify',
            modifyTitle: '修改送货单',
            area: ['60%', 'auto'],
            onModifyOpened: function() {
            },

            removeUrl: 'order/remove',
            getUrl: 'order/{id}'
        });

        $('[lay-filter="lig-order-imp"]').click(function() {
            lig.importData({
                tplCode: 'delivery_data_import_tpl',
                importUrl: 'order/excel/imp',
                end: function() {
                    customerTable.reloadTable({done: tableDone});
                }
            });
        });

    })
</script>